package com.thinkTank.oa.service.impl;

import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkTank.oa.base.BaseServiceImpl;
import com.thinkTank.oa.dao.DemandMapper;
import com.thinkTank.oa.entity.Demand;
import com.thinkTank.oa.entity.Project;
import com.thinkTank.oa.service.DemandService;

@Transactional
@Service("demandService")
public class DemandServiceImpl extends BaseServiceImpl<Demand> implements DemandService {

    private DemandMapper demandMapper;
    
    @Autowired
    public void setDemandMapper(DemandMapper demandMapper) {
        this.demandMapper = demandMapper;
        setBaseMapper(demandMapper);
    }
    
    @Override
    public void importData(Demand demand, Consumer<Demand> action) {
        add(demand);
        action.accept(demand);
    }

	@Override
	public List<Map<Object, Object>> findDemandByIndex(Integer count) {
		// TODO Auto-generated method stub
		return demandMapper.findDemandByIndex(count);
	}
	
	@Override
	public void updateDemandContact(Demand demand) {
		demandMapper.updateDemandContact(demand);
	}
	
	@Override
	public List<Project> queryButtedProject(String demandId) {
		return demandMapper.queryButtedProject(demandId);
	}
	
	/**
	 * 通过需求联系人查询需求
	 * @author dongli
	 * @date 2018年11月2日
	 * @param pid
	 * @return
	 */
	public List<Demand> findDemandByPersonId(Demand demand){
		return demandMapper.findDemandByPersonId(demand);
	}
	
	
	@Override
	public List<Integer> queryStatistics(String beginDate, String endDate) {
		return demandMapper.queryStatistics(beginDate, endDate);
	}
}
